<template>
  <div class="wapper">
    <div class="title">我的全部购物车</div>
    <div class="cart__content" v-for="(item, index) in list" :key="index">
      <div class="cart__content__shopName">
        {{ item.shopName }}
      </div>
      <template v-for="(proItem, proIndex) in item.productList" :key="proIndex">
        <div class="cart__list" v-if="proItem.count > 0">
          <img class="cart__list__img" :src="proItem.imgUrl" alt="" />
          <div class="cart__list__info">
            <div class="cart__list__name">{{ proItem.name }}</div>
            <div class="cart__list__com">
              ￥{{ proItem.price }} x {{ proItem.count }}
              <div class="cart__list__totalPrice">
                ￥{{ (proItem.price * proItem.count).toFixed(2) }}
              </div>
            </div>
          </div>
        </div>
      </template>
    </div>
  </div>
  <Docker :currentIndex="1" />
</template>
<script>
import Docker from "../../components/Docker";
export default {
  name: "CartList",
  components: { Docker },
  setup() {
    const list = JSON.parse(localStorage.cartList || "{}");
    return { list };
  },
};
</script>
<style lang="scss" scoped>
@import "../../style/viriables.scss";
.wapper {
  overflow-y: scroll;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0.5rem;
  background-color: #eee;
  .title {
    margin-bottom: 0.16rem;
    line-height: 0.4rem;
    text-align: center;
    font-size: 0.16rem;
    color: $content-fontcolor;
    background-color: $white-color;
  }
  .cart__content {
    margin: 0 0.18rem 0.12rem 0.18rem;
    padding: 0.12rem 0.12rem 0.1rem 0.12rem;
    background-color: #fff;
    .cart__content__shopName {
      font-size: 0.16rem;
      margin-bottom: 0.12rem;
      font-weight: 700;
      color: #333;
    }
    .cart__list {
      display: flex;
      margin-bottom: 0.14rem;
      &__img {
        width: 0.4rem;
        height: 0.4rem;
        margin-right: 0.12rem;
      }
      &__info {
        flex: 1;
      }
      &__name {
        font-size: 0.14rem;
        font-weight: 700;
        margin-bottom: 0.1rem;
      }
      &__com {
        font-size: 0.12rem;
        color: $red-color;
      }
      &__totalPrice {
        float: right;
        font-size: 0.14rem;
        font-weight: 700;
        color: #333;
      }
    }
  }
}
</style>
